package Algorithms.jishi.niuke.huawei.mianshi;

import java.util.Scanner;

/**
 * description: <br>
 * createTime: 2020/12/3 15:31 <br>
 *
 * @author zzh
 */
public class RomanFigure {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        System.out.println(convertRomanToIntValue(str));
    }

    public static int convertRomanToIntValue(String str) {
        String temp = str.replaceAll("IV", "A")
                .replaceAll("IX", "B")
                .replaceAll("XL", "E")
                .replaceAll("XC", "F")
                .replaceAll("CD", "G")
                .replaceAll("CM", "H");
        String[] array = temp.split("");
        int result = 0;
        for (String s : array) {
            switch (s) {
                case "A":
                    result += 4;
                    break;
                case "B":
                    result += 9;
                    break;
                case "C":
                    result += 100;
                    break;
                case "D":
                    result += 500;
                    break;
                case "E":
                    result += 40;
                    break;
                case "F":
                    result += 90;
                    break;
                case "G":
                    result += 400;
                    break;
                case "H":
                    result += 900;
                    break;
                case "I":
                    result += 1;
                    break;
                case "V":
                    result += 5;
                    break;
                case "X":
                    result += 10;
                    break;
                case "L":
                    result += 50;
                    break;
                case "M":
                    result += 1000;
                    break;
            }
        }
        return result;
    }
}
